package com.xizimall.rest.controller;

import org.apache.http.impl.cookie.PublicSuffixFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJacksonValue;
import org.springframework.stereotype.Controller;
/**
 * 商品分类列表
 * <p>Title: ItemCatController</p>
 * <p>Description: </p>
 * <p>华南理工大学研究生</p> 
 * @author	李隆熹
 * @date	2018年4月17日下午10:22:13
 * @version 1.0
 */
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xizimall.rest.pojo.CatResult;
import com.xizimall.rest.service.ItemCatService;
import com.xizimall.common.utils.JsonUtils;
@Controller
public class ItemCatController {
	
	@Autowired
	ItemCatService itemCatService;
	
   @RequestMapping(value="/itemcat/list",produces=MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8")
     @ResponseBody
   public String getItemCatList(String callback){
	   CatResult catResult=itemCatService.getItemCatList();
	   //把pojo转换成字符串
	   String json=JsonUtils.objectToJson(catResult);
	   //拼装返回值
	   String result=callback+"("+json+");";
	   return result;
	   
   }
   /*@RequestMapping("/itemcat/list")
	@ResponseBody
	public Object getItemCatList(String callback) {
		CatResult catResult = itemCatService.getItemCatList();
		MappingJacksonValue mappingJacksonValue = new MappingJacksonValue(catResult);
		mappingJacksonValue.setJsonpFunction(callback);
		return mappingJacksonValue;
	}*/
}
